package com.starview.star.operators.ast.runtime;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.Location;
import com.starview.platform.data.type.TypeUtils;
import com.starview.star.compiler.ast.ASyntax;
import com.starview.star.operators.CafeEnter;

public class AstLocation implements IFunction
{
  public static final String name = "astLocation";

  @CafeEnter
  public static IValue enter(ASyntax term)
  {
    return term.getLoc();
  }

  @Override
  public IValue enter(IValue... args) throws EvaluationException
  {
    return enter((ASyntax) args[0]);
  }

  @Override
  public IType getType()
  {
    return funType();
  }

  public static IType funType()
  {
    return TypeUtils.functionType(ASyntax.type, Location.type);
  }
}
